#define _CRT_SECURE_NO_WARNINGS 1

#include <iostream>
using namespace std;


int main()
{
	int year, n;
	while (cin >> year >> n)
	{
		int _monthday[] = { 0,31,59,90,120,151,181,212,243,273,304,334,365 };

		int i = 0;
		for (i = 0; i < n; ++i)
		{
			if (n <= _monthday[i])
				break;
		}
		if ((year % 400 == 0) || ((year % 100 != 0) && (year % 4 == 0)))
		{
			if (i == 2)
				++_monthday[2];
			if (i > 2)
				--n;
		}
		int month = i;
		int day = 0;
		if (i > 1)
			day = n - _monthday[i - 1];
		printf("%04d-%02d-%02d\n", year, month, day);
	}
}
